package com.zjitc.service;

import com.zjitc.model.User;

import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @author Administrator
 */
public interface UserService {

    /**
     * 通过用户名验证用户是否存在
     *
     * @param username
     * @return
     */
    boolean verifyUsername(String username);

    /**
     * 通过rabbitMQ接收的信息进行用户的注册
     *
     * @param user
     * @return
     * @throws UnsupportedEncodingException
     * @throws NoSuchAlgorithmException
     */
    int register(User user) throws UnsupportedEncodingException, NoSuchAlgorithmException;

    /**
     * 用户接收邮件信息进行激活，user --state-->1
     *
     * @param uid
     * @param code
     * @return
     */
    boolean active(String uid, String code);

    /**
     * 用户登录
     *
     * @param username
     * @param password
     * @param session
     * @return
     * @throws UnsupportedEncodingException
     * @throws NoSuchAlgorithmException
     */
    int login(String username, String password, HttpSession session)
            throws UnsupportedEncodingException, NoSuchAlgorithmException;

    /**
     * 分页形式查看所有用户
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<User> findAll(int pageNum, int pageSize);

    /**
     * 更新用户
     *
     * @param user
     */
    void update(User user);

    /**
     * 根据id进行删除
     *
     * @param id
     */
    void deleteById(String id);

    /**
     * 查找用户
     *
     * @param uid
     * @return
     */
    User findByUid(String uid);
}
